<?php
namespace app\admin\controller;
//导入Controller
use think\Controller;
//导入Db
use think\Db;
//导入session
use think\Session;
class Evaluate extends Allow
{
	//列表
    public function getindex()
    {
       $evaluate=Db::table("evaluate")->Paginate('5');
       // echo '<pre>';
       // var_dump($evaluate);exit;
       return $this->fetch("evaluate/index",['evaluate'=>$evaluate]);
    }

    public function getreply(){
       $request=request();
       $id=$request->param("id");
       $evaluate=Db::table("evaluate")->where("id","{$id}")->select();
       return $this->fetch("evaluate/reply",['evaluate'=>$evaluate]);
    }
    public function postdoreply(){
      $request=request();
      $id=$request->param("id");
      $reply=$request->param("reply");
      if(Db::execute("update evaluate set reply='{$reply}' where id='{$id}'")){
        $this->success("评论回复成功","/adminevaluate/index");
      }else{
        $this->error("评论回复失败");
      }
    }
    public function getdisplay(){
      $request=request();
      $id=$request->param('id');
      $status=$request->param('status');
      if(Db::execute("update evaluate set status='{$status}' where id='{$id}'")){
        $this->redirect('/adminevaluate/index');
      }else{
        $this->redirect('/adminevaluate/index');
      }
    }  
}
